***HEADER**********************************************************

clear
clear matrix
set more off

foreach p in coefplot estout cibar {
	cap ssc install `p'
}

cap cd "***Set working directory here***"
use study2.dta, clear


***SAMPLE STATISTICS*************************************************

sum age edu female pol right if panel == 0
//For Supplementary Table 1


***BALANCE CHECK*******************************************************

eststo balance1: mlogit condition age female edu pol right, b(1) r rrr
eststo balance2: mlogit condition age female edu pol right if condition != 2, b(1) r rrr
eststo balance3: mlogit condition age female edu pol right if condition != 2 & condition != 3, b(1) r rrr

coefplot(balance1,label(Moral Self-Concept vs. Control) ciop(lc(gs0)) mc(gs0)) ///
		(balance2,label(Insufficient Progress vs. Control) ciop(lc(gs2)) mc(gs2)) ///
		(balance3,label(Endorsement vs. Control) ciop(lc(gs10)) mc(gs10)), ///
		drop(_cons) title("Study 2", color(black)) xline(1) eform xtitle(Odds ratio) ///
		legend(cols(1) ring(0) pos(4) bm(none) m(zero) si(small)) graphr(c(white))
graph export "../figures/suppfig1_2.eps", replace
eststo clear


***TREATMENT COMPLIANCE**************************************************

cap gen check2 = check
label var check2 "Moral Self-Concept"
cap gen check3 = check
label var check3 "Insufficient Progress"
cap gen check4 = check
label var check4 "Endorsement"

forvalues x = 2/4 {
	eststo compliance`x': mean(check`x') if condition == `x'
}

coefplot compliance2 compliance3 compliance4, omitted baselevels ///
		 mlabel format(%9.2f) mlabposition(12) mlabcolor(black) mc(black) ciop(lc(black)) ///
		 legend(off) xtitle("Completion rate") graphr(c(white)) ///
		 title("Study 2", color(black))
graph export "../figures/suppfig2_2.eps", replace
eststo clear


***MAIN EFFECTS*************************************************************

//SUPPLEMENTARY FIGURE 4

eststo itt_sc: probit support selfcon if condition == 1 | condition == 2, r
eststo itt_ip: probit support insuff if condition == 1 | condition == 3, r
eststo itt_en: probit support endorsement if condition == 1 | condition == 4, r

eststo cace_sc: ivprobit support (check2=selfcon) if condition == 1 | condition == 2, first
eststo cace_ip: ivprobit support (check3=insuff) if condition == 1 | condition == 3, first
eststo cace_en: ivprobit support (check4=endorsement) if condition == 1 | condition == 4, first

coefplot (itt_ip, label(ITT) mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)) ///	
		 (itt_sc, label(ITT) mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)) ///	
		 (itt_en, label(ITT) mc(gs0) ciop(lc(gs0)) mlabcolor(gs0)) ///
		 (cace_ip, label(CACE) m(diamond) mc(gs6) ciop(lc(gs6)) mlabcolor(gs6)) ///
		 (cace_sc, label(CACE) m(diamond) mc(gs6) ciop(lc(gs6)) mlabcolor(gs6)) ///
		 (cace_en, label(CACE) m(diamond) mc(gs6) ciop(lc(gs6)) mlabcolor(gs6)), ///
	drop(`balance' control _cons) xline(1) eform xtitle(" " "Support for carbon tax (odds ratio)") ///
	mlabel format(%9.2f) mlabposition(12) mlabgap(*2) graphr(c(white)) ///
	rename(check2=selfcon check3=insuff check4=endorsement) ///
	legend(ring(0) pos(5) si(small) cols(1) bm(medium) order(2 8))
graph export "../figures/suppfig4.eps", replace


//FIGURE 4

cibar supp if condition == 1 | condition == 4, over1(condition) over2(green) ///
	barg(4) barc(gs1 gs7) ciopts(lc(gs10) lp(dash)) ///
	gr(yti("Policy support (proportion)                    " " ") ylab(0(0.2)1,nogrid) ///
	xti(" " "Subjective importance of energy & environment") ///
	graphr(c(white)) leg(ring(0) r(1) pos(2) si(small) cols(1) bm(medium)))
graph export "../figures/fig4.eps", replace

//SUPPLEMENTARY TABLE 4

eststo: probit support endorsement##c.green age edu female pol right if condition == 1 | condition == 4, r
estadd local controls "Full"
esttab using "../tables/supptab4.rtf", replace compress onecell label se pr2 ///
	drop(age edu female pol right _cons) nobaselevels star(* 0.10 ** 0.05 *** 0.01) ///
	scalar("controls Controls") ///
	rename(1.green green, 1.endorsement endorsement, 1.endorsement#1.green "Endorsement x Subj. Importance") ///
	mtitles ("By subjective importance")	
eststo clear


log close
